from rest_framework_jwt.authentication import jwt_decode_handler


def get_user(request):
    token = request.COOKIES.get("token")
    if token != None:
        token_user = jwt_decode_handler(token)
        username = token_user['username']  # 获取用户id
    else:
        username = None
    return username

